home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / opbonus.arc / PWF2TXT.ARC / PWF2TXT.PAS < prev   
Pascal/Delphi Source File  |  1991-03-20  |  2KB  |  92 lines

  1. {
  2. Read a packed window file and write it to a text file. The PWF is usually
  3. written by PSCREEN, version 1.0, from Object Professional. The text file is
  4. suitable for incorporating in a word processor. PWF2TXT decompresses the PWF
  5. file and strips out video attributes. It does not remove control characters
  6. (arrows, smiley faces, and the like), so be careful with these, especially ^Z
  7. (#26).
  8.  
  9. Written 12/10/89, Kim Kokkonen, TurboPower Software
  10. CompuServe 76004,2611
  11.  
  12. Requires Object Professional to compile.
  13. }
  14.  
  15. {$R-,S-,I-,V-}
  16.  
  17. program Pwf2Txt;
  18.   {-Write packed window to text file}
  19. uses
  20.   dos,oproot,opstring,opcrt,opframe,opwindow;
  21. var
  22.   pwfname : pathstr;
  23.   txtname : pathstr;
  24.   txt : text;
  25.   pw : packedwindow;
  26.   vs : virtscreen;
  27.   i : word;
  28.   r : word;
  29.   s : string[80];
  30. begin
  31.   {validate command line}
  32.   if (paramcount = 0) or (paramcount > 2) then begin
  33.     writeln('PWF2TXT 1.0, by TurboPower Software');
  34.     writeln;
  35.     writeln('Usage: PWF2TXT PwfFile[.PWF] [TxtFile[.TXT]]');
  36.     writeln;
  37.     writeln('If TxtFile is not specified, writes to PwfFile.TXT.');
  38.     halt(1);
  39.   end;
  40.  
  41.   {build filenames}
  42.   pwfname := stupcase(defaultextension(paramstr(1), 'PWF'));
  43.   if paramcount = 1 then
  44.     txtname := forceextension(pwfname, 'TXT')
  45.   else
  46.     txtname := stupcase(defaultextension(paramstr(2), 'TXT'));
  47.  
  48.   {create virtual screen to display packed window in the background}
  49.   if not vs.alloc(50, 80) then begin
  50.     writeln('Error (', InitStatus, ') allocating virtual screen');
  51.     halt(1);
  52.   end;
  53.  
  54.   {read packed screen}
  55.   if not pw.read(pwfname) then begin
  56.     writeln('Error (', InitStatus, ') reading ', pwfname);
  57.     halt(1);
  58.   end;
  59.  
  60.   {create output file}
  61.   assign(txt, txtname);
  62.   rewrite(txt);
  63.   i := ioresult;
  64.   if i <> 0 then begin
  65.     writeln('Error (', i, ') creating ', txtname);
  66.     halt(1);
  67.   end;
  68.  
  69.   {activate virtual screen and display packed window there}
  70.   vs.activate;
  71.   pw.displayat(1, 1);
  72.   vs.deactivate;
  73.  
  74.   {read characters from virtual screen and write to file}
  75.   for r := 1 to pw.pwRows do begin
  76.     vs.readfrom(pw.pwCols, r, 1, s);
  77.     writeln(txt, trimtrail(s));
  78.     i := ioresult;
  79.     if i <> 0 then begin
  80.       writeln('Error (', i, ') writing to ', txtname);
  81.       halt(1);
  82.     end;
  83.   end;
  84.  
  85.   close(txt);
  86.   i := ioresult;
  87.   if i <> 0 then begin
  88.     writeln('Error (', i, ') closing ', txtname);
  89.     halt(1);
  90.   end;
  91. end.
  92.